package com.bjb.vr.operation.controller;

import com.bjb.vr.common.result.BaseErrorCode;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.common.service.OptCusLogoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @version 1.0.0
 * @description:客户配置管理-logo管理
 * @author: caihaibo
 * @createDate: 2022/9/16
 */
@RestController
@RequestMapping("/api/operation/v1")
public class CusLogoController {


	@Autowired
	OptCusLogoService optCusLogoService;
	/**
	 * 客户配置管理-logo管理-增加webLogo
	 * @param tenantId
	 * @param webLogoFile
	 * @return
	 */
	@PostMapping("/addCusWebLogo")
	public BaseResult<String> addCusWebLogo(@RequestParam("tenantId") String tenantId,@RequestParam("webLogoFile") MultipartFile webLogoFile){
		String logoPath = "";
		logoPath =  optCusLogoService.addWebCusLogo(tenantId,webLogoFile);
		if (StringUtils.isEmpty(logoPath)) {
			return CommonResult.Fail(BaseErrorCode.ERROR_ADD);
		}
		return CommonResult.Ok().setResult(logoPath);
	}

	/**
	 * 客户配置管理-logo管理-增加devLogo
	 * @param tenantId
	 * @param devLogoFile
	 * @return
	 */
	@PostMapping("/addCusDevLogo")
	public BaseResult addCusDevLogo(@RequestParam("tenantId") String tenantId,@RequestParam("devLogoFile") MultipartFile devLogoFile ){
		String logoPath = "";
		logoPath = optCusLogoService.addDevCusLogo(tenantId,devLogoFile);
		if (StringUtils.isEmpty(logoPath)) {
			return CommonResult.Fail(BaseErrorCode.ERROR_ADD);
		}
		return CommonResult.Ok().setResult(logoPath);
	}
}
